/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package managedbean;

import java.io.Serializable;
import javax.ejb.EJB;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.context.FacesContext;
import javax.faces.event.AbortProcessingException;
import org.primefaces.event.FileUploadEvent;
import session.stateless.StakeholderSessionBean;
import org.primefaces.model.UploadedFile;

@ManagedBean(name = "stakeholderManagerBean")
@RequestScoped
public class StakeholderManagedBean implements Serializable {

    @EJB
    private StakeholderSessionBean stakeholderSessionBean;
    private String stakeholderDesc;
    private String statusMessage;
    private String industryInfoTypeIds;
    private String selectedIndustry;
    private boolean stakeholderAdded;
    private String imgUrl; 
     private long stakeholderID; 

     
    /** Creates a new instance of StakeholderManagedBean */
    public StakeholderManagedBean() {
    }
    
    public void saveStakeholderPortalInfo() {
        try {
            
           // stakeholderAdded = stakeholderSessionBean.addStakeholderPortalInfo(getStakeholderDesc(), getIndustryInfoTypeIds(), getImgUrl());
           // if (stakeholderAdded == true) {
            //    statusMessage = "Stakeholder portal is added successfully";
            //} else {
             //   statusMessage = "Stakeholder portal is not added";
           // }
           // FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, statusMessage, ""));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    
   public void processFileUpload(FileUploadEvent event) throws AbortProcessingException {

        try{
            System.out.println("Uploaded: " + event.getFile().getFileName());
            FacesMessage msg = new FacesMessage("Succesful", event.getFile().getFileName() + " is uploaded.");
            
            FacesContext.getCurrentInstance().addMessage(null, msg);
  
        }
        catch(Exception ex){
            ex.printStackTrace();
        }
    }
   
   

    public String getStakeholderDesc() {
        return stakeholderDesc;
    }

    public void setStakeholderDesc(String stakeholderDesc) {
        this.stakeholderDesc = stakeholderDesc;
    }

    public String getIndustryInfoTypeIds() {
        return industryInfoTypeIds;
    }

    public void setIndustryInfoTypeIds(String industryInfoTypeIds) {
        this.industryInfoTypeIds = industryInfoTypeIds;
    }

    public String getSelectedIndustry() {
        return selectedIndustry;
    }

    public void setSelectedIndustry(String selectedIndustry) {
        this.selectedIndustry = selectedIndustry;
    }

    /**
     * @return the imgUrl
     */
    public String getImgUrl() {
        return imgUrl;
    }

    /**
     * @param imgUrl the imgUrl to set
     */
    public void setImgUrl(String imgUrl) {
        this.imgUrl = imgUrl;
    }

    /**
     * @return the stakeholderID
     */
    public long getStakeholderID() {
        return stakeholderID;
    }

    /**
     * @param stakeholderID the stakeholderID to set
     */
    public void setStakeholderID(long stakeholderID) {
        this.stakeholderID = stakeholderID;
    }

}
